﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using WinFormAssigment.DAO;
using WinFormAssigment.Entities;

namespace WinFormAssigment.BUS
{
    class AttendanceManager
    {
        public static DataTable GetStudentInClass(string classID)
        {
            string storedProcedure = Query.studentInClass;
            SqlParameter[] sqlParameter = Query.StudentInClass(classID);
            DataTable table = DatabaseInteraction.GetSelectTable(storedProcedure, sqlParameter);
            return table;
        }

        public static DataTable GetAllClassID()
        {
            string procGetClassID = Query.allClassID;
            DataTable table = DatabaseInteraction.GetSelectTable(procGetClassID);
            return table;
        }
        public static DataTable GetAllClassIdByTeacher(string teacherID)
        {
            string sp = Query.allClassIdByTeacher;
            SqlParameter[] sqlParametter = Query.AllClassIdByTeacher(teacherID);
            DataTable table = DatabaseInteraction.GetSelectTable(sp, sqlParametter);
            return table;
        }

        public static DataTable GetSubjectBySem(string sem)
        {
            string storedProcedure = Query.getSubject;
            SqlParameter[] sqlParameter = Query.GetSubject(sem);
            DataTable table = DatabaseInteraction.GetSelectTable(storedProcedure, sqlParameter);
            return table;
        }

        public static DataTable GetAllSem()
        {
            string sp = Query.getAllSem;
            DataTable table = DatabaseInteraction.GetSelectTable(sp);
            return table;
        }
        public static DataTable GetTotalSessionBySubject(string subjectName)
        {
            string sp = Query.getTotalSessionBySubject;
            SqlParameter[] sqlParameter = Query.GetTotalSessionBySubject(subjectName);
            DataTable table = DatabaseInteraction.GetSelectTable(sp, sqlParameter);
            return table;
        }

        public static bool InsertAttendance(Attendance a, AttendanceDetail ad)
        {
            string sp = Query.insertAttendance;
            SqlParameter[] sqlParameter = Query.InsertAttendance(a, ad);
            bool b = DatabaseInteraction.InteractionData(sp, sqlParameter);
            return b;
        }

        public static DataTable GetAttendanceByID(string classID, string attendanceID)
        {
            string sp = Query.getAttendanceByID;
            SqlParameter[] sqlParameter = Query.GetAttendanceByID(classID,attendanceID);
            DataTable table = DatabaseInteraction.GetSelectTable(sp,sqlParameter);
            return table;
        }
    }
}
